<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>06_居中测试</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .main {
            background-color: #ff0;
        }
        .center {
            background-color: lightgreen;
            width: 1000px;
            margin: 0 auto;
        }
        .card {
            width: 200px;
            height: 300px;
            border: 2px solid #000;
            background-color: lightcoral;
            margin: 0 auto;/*让块级元素卡片自身在版心内水平居中*/
            text-align: center;/*让卡片内的文字在卡片里水平居中*/
            line-height: 300px;/*让文字行高与卡片一样高，实现文字在卡片垂直居中*/
        }
    </style>
</head>
<body>
    <div class="main">
        <div class="center">
            <div class="card">我是内容</div>
            <div class="card">我是内容</div>
            <div class="card">我是内容</div>
        </div>
    </div>
</body>
</html>